home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
292_02
/
ast05.asm
< prev
next >
Wrap
Assembly Source File
|
1990-07-16
|
27KB
|
1,246 lines
.title assist05E2 february 18, 1985
;*
;* monitor for the MC146805E2 Evaluation Board
;*
;* (c) copyright 1985 motorola, inc.
;*
;*
;* the monitor has the following commands:
;*
;* r print registers
;*
;* d download from standard host
;*
;* h host communication
;*
;* a display/change a register
;*
;* x display/change x register
;*
;* c display/change condition codes
;*
;* e display/change timer data register
;*
;* f display/change timer control register
;*
;* p display/change program counter
;*
;* i display/change irq vector
;*
;* j display/change timer vector
;*
;* k display/change timer vector (wait mode)
;*
;* b display breakpoints
;*
;* b n xxxx set breakpoint n
;*
;* b n 0 clear breakpoint
;*
;* t trace one instruction
;*
;* t xxxx trace xxxx instructions
;*
;* m xxxx memory examine/change
;*
;* type <cr> to examine next
;* ^ to eamine previous
;* = to examine same
;* hh to change hex data
;* . to terminate command
;*
;* g continue execution from current pc
;*
;* g xxxx go execute pgm at specified address
;*
;*
;*
;*
;*
;*
;*
;*
monstr = 0x1800 ; start of monitor
workpg = 0x0010 ; start of monitor variables
numbkp = 3 ; number of breakpoints
duart = 0x17f0 ; duart address
prompt = '> ; prompt character
timer = 8 ; timer data register
timec = 9 ; timer control register
;*
;* equates
;*
;*
eot = 0x04 ; end of text
cr = 0x0d ; carriage return
lf = 0x0a ; line feed
sp = 0x20 ; space
bell = 0x07 ; control-g (bell)
swiop = 0x83 ; software interrupt op code
jmpop = 0xcc ; extended jump op code
ctla = 0x01 ; host communications default terminator
;*
;* work ram
;*
;*
.area ASST05 (ABS,OVR)
.setdp
.org workpg
bkptbl: .blkb 3*numbkp ; breakpoint table
asave: .blkb 1 ; temp save for a
swiflg: .blkb 1 ; swi function flag
work1: .blkb 1 ; chrin/load/store/putbyt
work2: .blkb 1 ; load/store/putbyte
addrh: .blkb 1 ; high address byte
addrl: .blkb 1 ; low address byte
work3: .blkb 1 ; load/store/punch
work4: .blkb 1 ; store/punchpunch
work5: .blkb 1 ; trace/punch
work6: .blkb 1 ; trace
work7: .blkb 1 ; trace
work8: .blkb 1 ; timer restoration
work9: .blkb 1 ; timer restoration
workd: .blkb 1 ; timer restoration
worke: .blkb 1 ; timer restoration
pncnt: .blkb 1 ; punch breakpoint
chksum: .blkb 1 ; punch
cmd: .blkb 3
total: .blkb 1
savea: .blkb 1
sava: .blkb 1
savex: .blkb 1
vecram: .blkb 12 ; vectors
;*
;*
;*
;*
;*
.org monstr ; start of monitor
;*
;* monitor base string/table page
;* (must be at the begining of a page)
;*
;*
;*
mbase = . ; start of work page in rom
;* ; msgup must be the first in the page
msgup: .ascii /assist05E2 3.0/ ; fire-up message
msgnul: .byte eot ; end of string
msgerr: .ascii /- error -/
.byte bell
.byte eot
msgpc: .ascii / Pc A X Cc S/
.byte eot
vectab: .byte jmpop
.word tirq
.byte jmpop
.word tirq
.byte jmpop
.word irq
.byte jmpop
.word swi
;*
;*
;* g - start execuction
;* also used for p - display/set pc
;*
;*
cmdg: lda *work4
bit #0x80
bne nodipc ; don't display pc if a g command
jsr putsp ; send a space
jsr locstk ; obtain current sp-3
lda 7,x ; current pc high
jsr putbyt ; print pc high in hex
lda 8,x ; current pc low
jsr putbyt ; print pc low in hex
nodipc: jsr getadr ; obtain input address
bcc next ; do continue if done
gaddr: jsr locstk ; obtain current sp-3t-3
lda *addrh ; load pc high
sta 7,x ; into stack
lda *addrl ; load pc low
sta 8,x ; into stack also
next: lda *work4
bit #0x80
bne cont ; if g command then continue
jmp cmdnnl ; else just p command - don't continue
cont: jsr scnbkp ; init breakpoint scan parameters
goinsb: lda *bkptbl,x ; load high byte
cmp #0x00 ; check to see if empty
bne gstore
lda *bkptbl+1,x ; get next byte
cmp #0x00 ; really empty?
beq gonob
gstore: lda *bkptbl,x ; go get byte again
sta *addrh ; store high address
sta: lda *bkptbl+1,x ; load low address
sta *addrl ; load low
jsr load ; load opccode
sta *bkptbl+2,x ; store into table
lda #swiop ; replace with opcode
jsr store ; store in place
gonob: incx ; to
incx ; next
incx ; breakpoint
lda *pncnt ; count low
deca
sta *pncnt
bne goinsb ; loop if more
lda *swiflg ; flag breakpoints are in
coma
sta *swiflg
lda *work9 ; reset control register
sta *timec
lda *work8
sta *timer ; then user enviornment
lda *workd ; then the user's vectors
sta *vecram+4
lda *worke
sta *vecram+5
rti ; restart program
cmdmin: jmp cmderr
;*
;*
;* m - examine/change memory
;* mchnge - register change entry point
;*
;*
;*
cmdm: jsr getadr ; obtain address value
bcc cmdmin ; invalid if no address
cmdmlp: jsr prtadr ; print out address and space
mchnge: bsr load ; load acc w/byte
jsr crbyts ; print with a space
jsr getnyb ; see if change wanted
bcc cmdmdl ; branch no
jsr getby2 ; obtain full byte
bne cmdmin ; terminate if invalid hex
bcc cmdmdl ; branch if other delimiter
bsr store ; store new value
bcs cmdmin ; branch of store fails
jsr chrin ; obtain delimiter
;*
;* check out delimiters
cmdmdl: cmp #0x0d ; ? to next byte
beq cmdmlf ; branch if so
cmp #'^ ; ? to previous byte
beq cmdmbk ; branch if so
cmp #'= ; ? reexamine same byte
beq cmcmpr ; branch yes
cmp #'. ; ? carriage return
beq cmdmen1 ; branch yes
jsr pcrlf ; all else: give new line
cmdmen: jmp cmdnnl ; enter command handler
cmdmbk: lda *addrl ; ? low byte zero?
bne cmdmb2 ; no, just adjust it
lda *addrh
deca
sta *addrh ; down high for carry
cmdmb2: lda *addrl
deca
sta *addrl ; down low byte
bsr pcrlf ; to next line
bra cmdmlp ; to next byte
cmcmpr: bsr pcrlf
bra cmdmlp
cmdmlf: lda #cr ; send just a carriage return
jsr chrou2 ; output it
bsr ptrup1 ; up pointer by one
bra cmdmlp ; to next byte
cmdmen1:
jsr pcrlf
bra cmdmen ; add crlf to the <.>
;*
;*
;* load - load into a from address pointer addrh/addrl
;*
;* input: addrh/addrl = address
;*
;* output: a=byte from pointed location
;* x is transparent
;* work1, work2, work3 used
;*
;*
load: stx *work1 ; save x
ldx #0xc6 ; c6=lda 2 byte extended
ldstcm: stx *work2 ; put opcode in place
ldx #0x81 ; 81=rts
stx *work3 ; now the return
jsr *work2 ; execute built in routine
ldx *work1 ; restore x
rts ; and exit
;*
;*
;* store - store a at address in pointer addrh/addrl
;*
;* input: a=byte to store
;* addrh/addrl= address
;* output: c=0 store went ok
;* c=1 store did not take (not ram)
;* registers transparent (a not transparent on
;* invalid store)
;*
;*
store: stx *work1 ; save x
ldx #0xc7 ; c7=sta 2 byte extended
bsr ldstcm ; call store routine
sta *work4 ; save value stored
bsr load ; attempt load
cmp *work4 ; valid store?
beq strts ; branch if valid
sec ; show invalid store
strts: rts ; return
;*
;*
;* ptrup1 - increment memory pointer
;*
;*
ptrup1: lda *addrl
inca
sta *addrl ; increment low byte
bne prtrts ; non zero means no carry
lda *addrh
inca
sta *addrh ; increment high byte
prtrts: rts ; return to caller
;*
;*
;* putbyt - print a in hex
;*
putbyt: sta *work1 ; save a
lsra ; shift to
lsra ; left hex
lsra ; digit
lsra ; shift high nybble down
bsr putnyb ; print it
lda *work1
;*
;* fall into putnyb
;*
;*
;* putnyb - print lower nybble of a in hex
;* a,x transparent
;*
;*
putnyb: and #0xf ; mask off high nybble
add #'0 ; add ascii zero
cmp #'9 ; check for a-f
bhi putny2
jmp chrout ; ok, send out
putny2: add #'a-'9-1 ; adjustment for hex a-f
jmp chrout ; now send out
;*
;*
;* pdata - print monitor string after cr/lf
;* pdata1 - print monitor string
;* pcrlf - print cr/lf
;*
;* input: x=offset to string in base page
;*
;*
pcrlf: ldx #msgnul-mbase ; load null string address
pdata: lda #cr ; prepare carriage return
pdloop: jsr chrout ; send next character
pdata1: lda mbase,x ; load next character
incx